import java.io.*;

public class Demo {
    public static void main1(String[] args) {
        try(InputStream inputStream = new FileInputStream("C:\\比特\\Java\\Gitee\\java\\文件操作\\src\\Demo.txt")) {
            byte[] bytes = new  byte[1024];
            while (true) {
                int n = inputStream.read(bytes);
                if(n == -1) break;
                for (int i = 0; i < n; i++) {
                    System.out.printf("0x%x\n",bytes[i]);
                }
            }

        }catch (IOException e) {
            e.printStackTrace();
        }
    }

    public static void main(String[] args) {
        try (OutputStream outputStream = new FileOutputStream("C:\\比特\\Java\\Gitee\\java\\文件操作\\src\\Demo.txt")) {
            byte[] bytes = {(byte) 0xe4, (byte) 0xbd, (byte) 0xa0, (byte) 0xe5,(byte)  0xa5, (byte) 0xbd};
            outputStream.write(bytes);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
